//
//  Scenic.swift
//  ImGuider X
//
//  Created by llt on 2018/9/14.
//  Copyright © 2018年 imguider. All rights reserved.
//

import UIKit
import CoreLocation

class Scenic: NSObject,Codable {

    var ralationId:String?
    
    var id,viewname,ename,website,openinfo,telephone,address,pictures:String?
    var lat,lng:Double?
    var hasmap,inroom,visit,guides,rank:Int?
    var lines: [Line]?
    
    var pictureArray:[String]? {
        
        return pictures?.components(separatedBy: ",").compactMap({ str -> String? in
            
            return str.count > 0 ? str : nil
        })
    }
    
    var coor:CLLocationCoordinate2D? {
        
        guard let lat = lat, let lng = lng else {
            
            return nil
        }
        
        let coor = CLLocationCoordinate2D(latitude: lat, longitude: lng)
        
        if CLLocationCoordinate2DIsValid(coor) {
            
            return coor
        }
        
        return nil
    }
}
